//
//  RequestServiceForData.m
//  aiqiangua2
//
//  Created by 王锦章 on 15/11/6.
//  Copyright © 2015年 王锦章. All rights reserved.
//

#import "RequestServiceForData.h"
#import "MApi.h"
@interface RequestServiceForData ()<ServiceCallback>

@end


@implementation RequestServiceForData

- (void)postLocationString:(NSString *)location device:(NSString*)device passData:(passData)sender {
    MApi *postlocation = [[MApi alloc] initWithSid:@"LOCATION" andCallback:self];
    HttpQuery *query = [postlocation newQuery];
    [query addParam:@"point" andValue:location];
    [query addParam:@"device" andValue:device];
    [postlocation getWithPath:@"/phptest/location.php" andQuery:query];
    passBlock = sender;
}

#pragma mark - 数据返回
-(void)callbackWithResult:(ServiceResult *)result forSid:(NSString *)sid
{
    //NSLog(@"%@-%@",sid,result.data);
    if ([result.data[@"success"] intValue]==0)
    {
        //NSLog(@"error_desc = %@",result.data[@"error_desc"]);
    }
    passBlock(result.data);
}

#pragma mark 代码块传值
-(void)passData:(passData)sender
{
    passBlock = sender;
}

#pragma mark 单例
+(id)requestOnly
{
    static RequestServiceForData*request = nil;
    if (!request)
    {
        request = [[RequestServiceForData alloc]init];
    }
    return request;
}
@end
